package com.seuic.hnjiningposapp.hnapps.ui.view.dialog;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.CenterPopupView;
import com.seuic.hnjiningposapp.R;
import com.socks.library.KLog;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 确认交易信息
 */
public class SureDealPopup extends CenterPopupView {
    Unbinder bind;
    @BindView(R.id.sure_deal_info_title)
    TextView sureDealInfoTitle;
    @BindView(R.id.sure_deal_info_numtext)
    TextView sureDealInfoNumtext;
    @BindView(R.id.sure_deal_username)
    TextView sureDealusername;
    @BindView(R.id.sure_deal_info_moneytext)
    TextView sureDealInfoMoneytext;
    @BindView(R.id.sure_deal_info_nobtn)
    Button sureDealInfoNobtn;
    @BindView(R.id.sure_deal_info_okbtn)
    Button sureDealInfoOkbtn;

    Context mContext;
    //操作类型
    String mOperation_name;
    //账号
    String mUserName;
    //卡号
    String mCardNum;
    //金额
    String mMoney;

    OnNextClicklistener mOnNext;

    public SureDealPopup(@NonNull Context context, String Operation_name, String username,
                         String cardNum, String money,
                         OnNextClicklistener onNext) {
        super(context);
        this.mContext = context;
        this.mOperation_name = Operation_name;
        this.mUserName = username;
        this.mCardNum = cardNum;
        this.mMoney = money;
        this.mOnNext = onNext;
    }

    public SureDealPopup(@NonNull Context context, OnNextClicklistener onNext) {
        super(context);
        this.mOnNext = onNext;

    }

    public String getmOperation_name() {
        return mOperation_name;
    }

    public void setmOperation_name(String mOperation_name) {
        this.mOperation_name = mOperation_name;
    }

    public String getmUserName() {
        return mUserName;
    }

    public void setmUserName(String mUserName) {
        this.mUserName = mUserName;
    }

    public String getmCardNum() {
        return mCardNum;
    }

    public void setmCardNum(String mCardNum) {
        this.mCardNum = mCardNum;
    }

    public String getmMoney() {
        return mMoney;
    }

    public void setmMoney(String mMoney) {
        this.mMoney = mMoney;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        bind = ButterKnife.bind(this);
        sureDealInfoTitle.setText(mOperation_name);
        sureDealInfoNumtext.setText(mCardNum);
        sureDealusername.setText(mUserName);
        sureDealInfoMoneytext.setText(mMoney);


    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.sure_deal_info_layout;
    }

    @OnClick({R.id.sure_deal_info_nobtn, R.id.sure_deal_info_okbtn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.sure_deal_info_nobtn:
                //上一步
                mOnNext.LastStep();
                break;
            case R.id.sure_deal_info_okbtn:
                //确定
                mOnNext.onNext();
                break;
        }
    }


    public interface OnNextClicklistener {
        //确定交易信息
        void onNext();

        //上一步
        void LastStep();
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
        //注解解绑
        if (bind != null && bind != Unbinder.EMPTY) {
            bind.unbind();
        }
        this.bind = null;
    }

}
